home *** CD-ROM | disk | FTP | other *** search
- //-------------------------------------------------------------------//
- //
- // Syntax: loaddir ( DIRNAME )
- //
- // Description:
- //
- // An Acorn replacement for loaddir - Ian Mc Loughlin
- //
- // loaddir loads all of the files in the directory DIRNAME. DIRNAME
- // is a string identifying the directory of files to be loaded.
- // Unfortunately, at the moment ALL FILES, not just r-files are loaded.
- // Attempts to load a non r-file will cause an error and abort.
- //
- // Example:
- // > loaddir ("adfs::4.$.Maths"); - Load all files from maths directory
- // > loaddir ("."); - Load all files from CSD
- //
- //-------------------------------------------------------------------//
-
- loaddir = function( dir )
- {
- local(dir);
- local(var1);
- local(files);
- local(i);
- local(j);
- i=0;
- if(dir==".")
- {
- dir="";
- else
- dir=dir+".";
- }
- // Use OS to produce a directory listing
- system("info "+dir+"* { > "+dir+"mycat }");
- // Read through directory listing
- while(1)
- {
- i++;
- var1=getline(dir+"mycat");
- if(length(var1)==0) {break;}
- files[i]=var1.[1];
- }
- close(dir+"mycat");
- // Delete the directory listing file
- system("delete "+dir+"mycat");
- // Print out the list of files to be read
- files
- for(j in 1:i-1)
- {
- // Don't load directory file (may still be there...)
- if(files[j] != "mycat")
- { load(dir+files[j]); }
- }
- };
-